using System;
using System.Windows.Controls;
using ibba.src.noriskbo.ViewModels;
using ibba.src.sl.componentes;

namespace ibba.src.noriskbo
{
    public enum ButtonClickType
    {
        btnStatusRA = 0,
        btnStatusEA = 1,
        btnStatusEE = 2,
        btnStatusAP = 3,
        btnStatusBO = 4,
        btnStatusBV = 5,
        btnStatusEB = 6,
        btnStatusBE = 7,
        btnRefresh  = 8
 
    }

    public partial class PainelStatusLM : UserControl
    {
        #region " Eventos "

        public delegate void ButtonClick(object sender, ButtonClickType e);
        public event ButtonClick OnButtonClick;
        
        #endregion

        public PainelStatusLM()
        {
            InitializeComponent();
        }
        
        private void Botao_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            CustomButtonBar btn = sender as CustomButtonBar;

            var botao = (ButtonClickType)Enum.Parse(typeof(ButtonClickType), btn.Name, true);

            if (OnButtonClick != null && botao != ButtonClickType.btnRefresh)
                OnButtonClick(sender, botao);
            else
                switch (botao)
                {
                    case ButtonClickType.btnStatusRA:
                        App.MainPage.NavigateTo("/PageLancamentosManuais/rascunhos");
                        break;
                    case ButtonClickType.btnStatusEA:
                    case ButtonClickType.btnStatusEE:
                    case ButtonClickType.btnStatusEB:
                    case ButtonClickType.btnStatusBE:                        
                        App.MainPage.NavigateTo("/PageLancamentosManuais/pendentes");
                        break;
                    case ButtonClickType.btnStatusAP:
                        App.MainPage.NavigateTo("/PageLancamentosManuais/aprovados");
                        break;
                    case ButtonClickType.btnStatusBO:
                        App.MainPage.NavigateTo("/PageLancamentosManuais/baixas");
                        break;
                    case ButtonClickType.btnStatusBV:
                        App.MainPage.NavigateTo("/PageLancamentosManuais/vencidas");
                        break;
                    //case ButtonClickType.btnStatusEB: //LUD10054
                    //    App.MainPage.NavigateTo("/PageLancamentosManuais/pendentesbaixa");
                    //    break;
                    //case ButtonClickType.btnStatusBE: //LUD10054
                    //    App.MainPage.NavigateTo("/PageLancamentosManuais/pendentesexclusaobaixa");
                    //    break;
                    case ButtonClickType.btnRefresh:
                        (this.LayoutRoot.DataContext as PainelStatusLMViewModel).AtualizarDados();
                        break;

                    default:
                        return;
                }
            
        }
    }
}
